package main

import "fmt"

type Income interface {
	calculate() int
	source() string
}

type FixedBilling struct {
	projectName  string
	biddedAmount int
}

type TimeAndMaterial struct {
	projectName string
	noofHours   int
	hourlyRate  int
}

type Advertisement struct {
	adName     string
	CPC        int
	noofClicks int
}

func (Fb FixedBilling) calculate() int {
	return Fb.biddedAmount
}

func (Fb FixedBilling) source() string {
	return Fb.projectName
}

func (Tm TimeAndMaterial) calculate() int {
	return Tm.noofHours * Tm.hourlyRate
}

func (Tm TimeAndMaterial) source() string {
	return Tm.projectName
}

func (a Advertisement) calculate() int {
	return a.CPC * a.noofClicks
}

func (a Advertisement) source() string {
	return a.adName
}

func calculateNetIncome(ic []Income) {
	var netincome int = 0
	for _, Income := range ic {
		//fmt.Println(ic)
		fmt.Println(Income.source(), Income.calculate())
		netincome += Income.calculate()
	}
	fmt.Println(ic)
	fmt.Println(netincome)
}

func main() {
	project1 := FixedBilling{projectName: "Project 1", biddedAmount: 5000}
	project2 := FixedBilling{projectName: "project 2", biddedAmount: 10000}
	project3 := TimeAndMaterial{projectName: "project3", noofHours: 160, hourlyRate: 25}
	AD1 := Advertisement{adName: "AD1", CPC: 2, noofClicks: 500}
	AD2 := Advertisement{adName: "AD2", CPC: 3, noofClicks: 1500}
	incomeStreams := []Income{project1, project2, project3, AD1, AD2}
	calculateNetIncome(incomeStreams)
}
